package com.hcryan.djm.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hcryan.djm.pojo.entity.Calendar;
import com.hcryan.djm.result.WebResult;
import com.hcryan.djm.service.CalendarService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ryanwdj
 * @since 2025/5/8
 */
@RestController
@RequestMapping("/calendar")
@Slf4j
@Api("日历")
public class CalendarController {

    @Autowired
    private CalendarService calendarService;

    @GetMapping("/list")
    public WebResult<List<Calendar>> list(String startDate, String endDate) {
        LambdaQueryWrapper<Calendar> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper
                .select(Calendar::getDate, Calendar::getIsWorkday)
                .between(Calendar::getDayName, startDate, endDate);
        List<Calendar> list = calendarService.list(queryWrapper);
        return WebResult.success(list);
    }
}
